package com.lingyue.commons.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by IntelliJ IDEA.
 *
 * @Description: TODO
 * @Author: BaiJinhua
 * @Date: 2019/11/26 23:53
 * @See: com.lingyue.common.enums
 * @Version: 1.0
 * Copyright: Copyright (c) 2019
 */
public enum CampaignEnum {

    UNALLOCATED(0,"0","未分配"),
    UNTREATED(7,"7","已分配未处理"),

    CUSTOMER_RESERVATION(10,"10","客户预约"),
    EXPERT_ADVICE(11,"11","转入线索"),
    FOLLOW(12,"12","持续跟进"),
    WILLING_CUSTOMER(13,"13","意向客户"),

    CUSTOMER_REJECTION(20,"20","客户拒绝"),
    NSP_REJECTION(21,"21","NSP拒绝"),
    CUSTOMER_TO_SHOP(22,"22","客户到店"),
    SF_TRANSACTION(23,"23","金融成交"),
    UC_TRANSACTION(24,"24","二手车成交"),
    SUCCESS_VISIT(25,"25","成功联系"),

    LEAD_DELETE(98,"98","删除"),
    LEAD_FAILURE(99,"99","失效"),
    ;
    int status;
    String value;
    String msg;

    CampaignEnum() {
    }

    CampaignEnum(int status, String value, String msg) {
        this.status = status;
        this.value = value;
        this.msg = msg;
    }

    public int status() {
        return this.status;
    }

    public String value() {
        return this.value;
    }

    public String msg() {
        return this.msg;
    }

    public static String getValue(int status) {
        for (CampaignEnum item : values()) {
            if (status == item.status()) {
                return item.value();
            }
        }
        return null;
    }

    public static String getMsg(int status) {
        for (CampaignEnum item : values()) {
            if (status == item.status()) {
                return item.msg();
            }
        }
        return null;
    }

    public static CampaignEnum getCampaignByStatus(int status){
        for (CampaignEnum item : values()) {
            if (status == item.status()) {
                return item;
            }
        }
        return CampaignEnum.LEAD_FAILURE;
    }

    public static int getStatus(String value) {
        if (StringUtils.isEmpty(value)) {
            return -1;
        }
        for (CampaignEnum item : values()) {
            if (value.equals(item.value())) {
                return item.status();
            }
        }
        return -1;
    }

    public static String getFollowState(int status){
        String result;
        switch (getCampaignByStatus(status)) {
            case UNALLOCATED:
                result = "未分配";
                break;
            case UNTREATED:
                result = "未处理";
                break;
            case CUSTOMER_RESERVATION:
            case EXPERT_ADVICE:
            case FOLLOW:
            case WILLING_CUSTOMER:
                result = "处理中";
                break;
            case CUSTOMER_REJECTION:
            case NSP_REJECTION:
            case CUSTOMER_TO_SHOP:
            case SF_TRANSACTION:
            case UC_TRANSACTION:
            case SUCCESS_VISIT:
                result = "已完成";
                break;
            case LEAD_FAILURE:
                result = "已失效";
                break;
            default:
                result = "";
                break;
        }
        return result;
    }

    public static String getHandleState(int status){
        String result;
        switch (getCampaignByStatus(status)){
            case CUSTOMER_TO_SHOP:
            case SF_TRANSACTION:
            case UC_TRANSACTION:
            case SUCCESS_VISIT:
                result = "成功";
                break;
            case CUSTOMER_REJECTION:
            case NSP_REJECTION:
                result = "拒绝";
                break;
            default:
                result = getMsg(status);
                break;
        }
        return result;
    }
}
